Socket
Socket
Sign inDemoInstall

is-subdir

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-subdir

Return whether a directory is a subdirectory of another directory


Version published
Maintainers
1
Created

What is is-subdir?

The is-subdir npm package is a utility that helps determine if a given directory is a subdirectory of another directory. This can be useful in various scenarios such as validating file paths, ensuring security by restricting access to certain directories, and more.

What are is-subdir's main functionalities?

Check if a directory is a subdirectory

This feature allows you to check if a given directory is a subdirectory of another directory. In this example, '/home/user/projects/my-app' is a subdirectory of '/home/user/projects', so the function returns true.

const isSubdir = require('is-subdir');
const parentDir = '/home/user/projects';
const subDir = '/home/user/projects/my-app';
console.log(isSubdir(parentDir, subDir)); // true

Check if a directory is not a subdirectory

This feature allows you to check if a given directory is not a subdirectory of another directory. In this example, '/home/user/other-projects' is not a subdirectory of '/home/user/projects', so the function returns false.

const isSubdir = require('is-subdir');
const parentDir = '/home/user/projects';
const notSubDir = '/home/user/other-projects';
console.log(isSubdir(parentDir, notSubDir)); // false

Other packages similar to is-subdir

Keywords

FAQs

Package last updated on 05 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc